home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / comm / irc / KuangEleven3Gm.lha / Kuang Eleven 3 / Rexx / voteman.amirx < prev   
Text File  |  1998-05-09  |  8KB  |  298 lines

  1. /* $VER: Voteman.amirx 3.0 (9.5.98) Vote Manager for AmIRC/K¹¹2.8+
  2.  
  3. Vote Manager for AmIRC/K¹¹2.8+ by Ariel Magnum
  4. ==============================================
  5.  
  6. Introduction:
  7. -------------
  8. Now you can take votes on anything in your channel!
  9. This is an easy to use and POWERFULL script that will allow
  10. you to make your channel a prospering democracy.
  11.  
  12. Distribution:
  13. -------------
  14. *IMPORTANT*
  15. This script is NOT freeware!Dont spread this script to
  16. people who are not veteran ops becuase otherwise it will
  17. become a major hassle with lamers using  it everywhere.
  18.  
  19. Features
  20. --------
  21. - Vote via CTCP commands and Public channel commands
  22. - One vote per person
  23. - Vote notifier : it keeps track of those who havnt voted
  24.   and remindes them to vote at time-delayed intervals.
  25. - Abstaining is part of the program.
  26.  
  27. Install
  28. -------
  29. Just do /rx voteman install to install this thing.
  30. My suggestion : DONT save your K11 prefs becuase
  31. it adds one CTCP plugin and one PUB plugin.Once the vote
  32. is over do /load to nuke those plugins from the K11 config.
  33. Or you can remove them from the K11 UI.
  34.  
  35. Usage
  36. -----
  37. First you have to edit Kuang11/Vote as described in the example
  38. this file holds the options , topic etc.
  39. enter /voteman to see the options.
  40.  
  41. */
  42.  
  43.  
  44. /*************** CONFIGURATION ********************/
  45. time=1     /* Delay between Reminders             */
  46. retries=5  /* Number of vote reminders to attempt */
  47. /******************** END *************************/
  48.  
  49. options results
  50. signal on syntax
  51. parse upper arg command .
  52. doecho="ECHO P="d2c(27)"b«VoteMan»"
  53. out='SAY'
  54. parse UPPER VERSION ver;freq=substr(word(ver,6),1,2)
  55. if find('START ABORT DISPLAY SHOW COUNT INSTALL REMINDER',command)=0|command=''|command='?' then do
  56.     cecho('Usage :')
  57.     cecho('/VOTEMAN START    - Start a new vote')
  58.     cecho('/VOTEMAN ABORT    - Stop vote , clear results')
  59.     cecho('/VOTEMAN SHOW     - Show you the results')
  60.     cecho('/VOTEMAN DISPLAY  - Display results')
  61.     cecho('/VOTEMAN COUNT    - Vote complete : Display results')
  62.     cecho('/VOTEMAN REMINDER - Start reminder to remind people to vote')
  63.     exit
  64. end
  65. signal value command
  66. exit
  67. install:
  68. /**/
  69. if ~exists('Rexx/CTCP/Vote.amirx')|~exists('Rexx/Pub/Vote.aMIRX')|~exists('Rexx/Voteman.amirx') then do
  70.     cecho('Missing scripts!')
  71.     exit
  72. end
  73. if find(getclip('sc_extrctcp'),'VOTE')~=0|find(upper(getclip('sc_extrscr')),'VOTE.AMIRX')~=0|find(getclip('sc_pubcmd'),'VOTE')~=0|find(upper(getclip('sc_pubscr')),'VOTE.AMIRX')~=0 then do
  74.     cecho('Plugins already installed!')
  75. end
  76. else do
  77.     call setclip('sc_extrctcp',strip(getclip('sc_extrctcp') 'VOTE'))
  78.     call setclip('sc_pubcmd',strip(getclip('sc_pubcmd') 'VOTE'))
  79.     call setclip('sc_pubscr',strip(getclip('sc_pubscr') 'VOTE.AMIRX'))
  80.     call setclip('sc_extrscr',strip(getclip('sc_extrscr') 'VOTE.AMIRX'))
  81.     cecho('Installed plugins.')
  82. end
  83. 'SAY /ALIAS VOTEMAN /RX VOTEMAN %p'
  84. cecho('Install complete!')
  85. exit
  86. /**/
  87.  
  88. start:
  89. /**/
  90. if ~exists('Rexx/CTCP/Vote.amirx')|~exists('Rexx/Pub/Vote.aMIRX')|find(getclip('sc_extrctcp'),'VOTE')=0|find(upper(getclip('sc_extrscr')),'VOTE.AMIRX')=0|find(getclip('sc_pubcmd'),'VOTE')=0|find(upper(getclip('sc_pubscr')),'VOTE.AMIRX')=0 then do
  91.     cecho('Error : Incorrect installation')
  92.     cecho('1. You must have the file Rexx/CTCP/Vote.amirx CTCP plugin')
  93.     cecho('2. You must have the file Rexx/Pub/Vote.amirx Command plugin')
  94.     cecho('3. You must add the CTCP Plugin via the K¹¹ GUI as command VOTE script vote.amirx')
  95.     cecho('4. You must add the Command Plugin via the K¹¹ GUI as command VOTE script vote.amirx')
  96.     exit
  97. end
  98. channels=getclip('sc_autochannels')
  99. if channels~='ALL' then do
  100.     "GETCHANNEL"
  101.     channel=upper(result)
  102.     if find(channels,channel)=0 then do
  103.         call setclip('sc_autochannels',channels channel)
  104.         cecho('Adding this channel as AutoChannel')
  105.    end
  106. end
  107.  
  108. if ~open(1,'Kuang11/Vote','R') then do
  109.     cecho('Vote File Kuang11/Vote does not exists.')
  110.     exit
  111. end
  112. i=-1
  113. do until eof(1)
  114.     line=strip(readln(1))
  115.     if left(line,1)='#'|line='' then iterate
  116.     if i=-1 then topic=line
  117.     else option.i=line
  118.     i=i+1
  119. end
  120. close(1)
  121. options=i-1
  122. call clear
  123. call Setclip('st_vt_topic',topic)
  124. do i=0 to options
  125.     call setclip('st_vt_desc'i,option.i)
  126. end
  127. call setclip('st_vt_opts',options)
  128. "GETUSERS"
  129. users=compress(result,'+@')
  130. call setclip('st_vt_users',users)
  131. out und('K¹¹ Vote on' bld(topic) "Starting :")
  132. do i=0 to options
  133.     out i"." option.i
  134. END
  135. call instruct
  136. exit
  137. /**/
  138.  
  139. reminder:
  140. /**/
  141. options=getclip('st_vt_opts')
  142. if options='' then do
  143.     cecho('No vote started')
  144.     exit
  145. end
  146. cecho('Vote Notifier starting' retries 'retries every ~'time 'minutes.')
  147. time=time*50*60;spent=0
  148. signal on halt
  149. do retries
  150.     call delay(max(0,time-spent*freq))
  151.     timer=time('S')
  152.     users=getclip('st_vt_users')
  153.     if users='' then do
  154.         cecho('All users voted!Vote reminder exiting.')
  155.         exit
  156.     end
  157.     nusers=''
  158.     do until users=''
  159.         parse var users nick users
  160.         if find(getclip('st_vt_users'),nick)=0 then iterate
  161.         "USERHOST" nick
  162.         host=result
  163.         if pos('@',host)=0 then iterate
  164.         parse var host . '@' host
  165.         if find(getclip('st_vt_voters'),host)~=0 then iterate
  166.         nusers=nusers nick
  167.         'QueueRAW NOTICE' nick ':Please Vote!'
  168.         /*call delay(2*freq)*/
  169.     end
  170.     nusers=strip(nusers)
  171.     call setclip('st_vt_users',nusers)
  172.     if nusers='' then do
  173.         cecho('All users notified.Exiting.')
  174.         exit
  175.     end
  176.     cecho('Reminded to vote :' words(nusers) ':' nusers)
  177.     spent=time('S')-timer
  178. end
  179. cecho('Done with reminders')
  180. exit
  181.  
  182. halt:
  183. cecho('Vote Notfier aborted.')
  184. exit
  185. /**/
  186.  
  187. show:
  188. /**/
  189. options=getclip('st_vt_opts')
  190. if options='' then do
  191.     cecho('No vote started')
  192.     exit
  193. end
  194. cecho(und('K¹¹ Vote on' bld(getclip('st_vt_topic')) 'Update :'))
  195. out=doecho
  196. string='Leader'
  197. call showstats
  198. exit
  199. /**/
  200.  
  201. display:
  202. /**/
  203. options=getclip('st_vt_opts')
  204. if options='' then do
  205.     cecho('No vote started')
  206.     exit
  207. end
  208.  
  209. out und('K¹¹ Vote on' bld(getclip('st_vt_topic')) 'Update :')
  210. string='Leader'
  211. call showstats
  212. call instruct
  213. exit
  214. /**/
  215.  
  216. count:
  217. /**/
  218. options=getclip('st_vt_opts')
  219. if options='' then do
  220.     cecho('No vote started')
  221.     exit
  222. end
  223.  
  224. out und('K¹¹ Vote on' bld(getclip('st_vt_topic')) 'Results :')
  225. string=bld('Winner')
  226. call showstats
  227. out bld('Vote complete!') 'Do not vote anymore.'
  228. call clear
  229. exit
  230. /**/
  231.  
  232. abort:
  233. /**/
  234. options=getclip('st_vt_opts')
  235. if options='' then do
  236.     cecho('No vote started')
  237.     exit
  238. end
  239. call clear
  240. cecho('Vote Aborted')
  241. exit
  242. /**/
  243.  
  244. /*shared*/
  245. /**/
  246. Showstats:
  247. novotes=words(getclip('st_vt_users'))
  248. max=0;winner=0;votes.=0
  249. do i=0 to options
  250.     votes.i=getclip('st_vt_cnt'i)
  251.     if votes.i='' then votes.i=0
  252.     if i=0 then do
  253.         out i'.' getclip('st_vt_desc'i) bld(votes.i)'/'novotes '(still havnt voted)'
  254.     end
  255.     else do
  256.         if votes.i>max then do
  257.             max=votes.i
  258.             winner=i
  259.         end
  260.         out i'.' getclip('st_vt_desc'i) bld(votes.i)
  261.     end
  262. end
  263. tied=''
  264. do i=1 to options
  265.     if votes.i=votes.winner&i~=winner then tied=tied i
  266. end
  267. tied=strip(tied)
  268. if tied='' then out string ':' winner 'with' max 'votes!'
  269. else out 'Vote tied :' translate(winner tied,',',' ') 'with' max 'votes!'
  270. return
  271. clear:
  272. do i=0 to options
  273.     call setclip('st_vt_desc'i)
  274.     call setclip('st_vt_cnt'i)
  275. end
  276. call setclip('st_vt_voters')
  277. call setclip('st_vt_users')
  278. call setclip('st_vt_opts')
  279. call setclip('st_vt_topic')
  280. return
  281. instruct:
  282. out "-------"
  283. "GETMYNICK"
  284. out "To vote secretly do /CTCP" result "VOTE [OPT]"
  285. out "or simply enter on this channel" getclip('sc_comprefix')"VOTE [OPT]"
  286. return
  287. bld:;bld = x2c('02');return bld||arg(1)||bld
  288. und:;und=x2c('1F');return und||arg(1)||und
  289. cecho:;doecho arg(1);return 0
  290. syntax:
  291. l=rc
  292. 'echo You have found a bug! report the lines below by E-Mail to Me at amagnum@ibm.net'
  293. 'echo Command :' command 'Arguments :' args
  294. 'echo' l ':' errortext(l)
  295. 'echo' SIGL ':' sourceline(SIGL)
  296. exit
  297. /**/
  298.